//
//  NKSettingController.m
//  NiKi
//
//  Created by qiang chen on 16/6/24.
//  Copyright © 2016年 qiang chen. All rights reserved.
//

#import "NKSettingController.h"
#import "NKFeedBackController.h"
#import "NKAboutUsController.h"

@interface NKSettingController ()<UITableViewDelegate,UITableViewDataSource>{
    
    IBOutlet UITableViewCell *_netWorkSettingCell;
    IBOutlet UITableViewCell *_shareCell;
    IBOutlet UITableViewCell *_feedBackCell;
    IBOutlet UITableViewCell *_aboutUsCell;
    IBOutlet UITableViewCell *_cacheCell;
    IBOutlet UITableViewCell *_cancleCell;
    IBOutlet UIView *_headV;
    __weak IBOutlet UITableView *_tableV;
    
    NSArray *_cells;
}

@end

@implementation NKSettingController

- (void)viewDidLoad {
    [super viewDidLoad];
    _cells = @[_netWorkSettingCell,_shareCell,_feedBackCell,_aboutUsCell,_cacheCell,_cancleCell];
    [self setupUI];
}

- (void)setupUI {
    self.navigationItem.title = @"设置";
    self.view.layer.contents = (id)[UIImage imageNamed:@"背景底图"].CGImage;
    
    _tableV.tableHeaderView = _headV;
}

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

#pragma mark - tableViewDelegate 
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return _cells.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    return _cells[indexPath.section];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    switch (indexPath.section) {
        case 2:
            [self.navigationController pushViewController:[NKFeedBackController new] animated:YES];
            break;
        case 3:
            [self.navigationController pushViewController:[NKAboutUsController new] animated:YES];
            break;
            
        default:
            break;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return indexPath.section == 0?65.f:50.f;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [UIView new];
    view.backgroundColor = [UIColor clearColor];
    return view;
}
@end
